﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace zad1
{
    class Program
    {
        enum Specialty
        {
            Informatics,
            SoftwareEngineering,
            CommunicationSystems,
            ComputerScience
        }

        enum Faculty
        {
            FacultyOfMathematicsAndInformatics,
            FacultyOfPhysics,
            FacultyOfBiology,
            FacultyOfChemistry,
            LawFaculty
        }

        enum University
        {
            SofiaUniversity,
            TechnicalUniversity,
            UNWE,
            NewBulgarianUniversity
        }

        class Student : ICloneable, IComparable<Student>
        {
            private string firstName;
            private string middleName;
            private string lastName;
            private string SSN;
            private string permanentAddress;
            private string mobilePhone;
            private string eMail;
            private int course;
            private University uni;
            private Faculty faculty;
            private Specialty spcialty;

            public Student(string firstName, string middleName, string lastName, string sSN, string permanentAddress,
                string mobilePhone, string eMail, int course, University university, Faculty faculty, Specialty spcialty)
            {
                this.firstName = firstName;
                this.middleName = middleName;
                this.lastName = lastName;
                SSN = sSN;
                this.permanentAddress = permanentAddress;
                this.mobilePhone = mobilePhone;
                this.eMail = eMail;
                this.course = course;
                this.uni = university;
                this.faculty = faculty;
                this.spcialty = spcialty;
            }

            public string FirstName
            {
                get
                {
                    return firstName;
                }
                set
                {
                    firstName = value;
                }
            }

            public string MiddleName
            {
                get
                {
                    return middleName;
                }
                set
                {
                    middleName = value;
                }
            }

            public string LastName
            {
                get
                {
                    return lastName;
                }
                set
                {
                    lastName = value;
                }
            }

            public string PSSN
            {
                get
                {
                    return SSN;
                }
                set
                {
                    SSN = value;
                }
            }

            public string PermanentAddress
            {
                get
                {
                    return permanentAddress;
                }
                set
                {
                    permanentAddress = value;
                }
            }

            public string MobilePhone
            {
                get
                {
                    return mobilePhone;
                }
                set
                {
                    mobilePhone = value;
                }
            }

            public string EMail
            {
                get
                {
                    return eMail;
                }
                set
                {
                    eMail = value;
                }
            }

            public int Course
            {
                get
                {
                    return course;
                }
                set
                {
                    course = value;
                }
            }

            public Program.University Uni
            {
                get
                {
                    return uni;
                }
                set
                {
                    uni = value;
                }
            }

            public Program.Faculty Faculty
            {
                get
                {
                    return faculty;
                }
                set
                {
                    faculty = value;
                }
            }

            public Program.Specialty Spcialty
            {
                get
                {
                    return spcialty;
                }
                set
                {
                    spcialty = value;
                }
            }

            public override bool Equals(object obj)
            {
                Student s = obj as Student;
                if (Object.ReferenceEquals(s, null))
                {
                    return false;
                }
                if (!this.FirstName.Equals(s.FirstName))
                {
                    return false;
                }
                if (!this.MiddleName.Equals(s.MiddleName))
                {
                    return false;
                }
                if (!this.LastName.Equals(s.LastName))
                {
                    return false;
                }
                if (!this.PSSN.Equals(s.PSSN))
                {
                    return false;
                }
                if (!this.PermanentAddress.Equals(s.PermanentAddress))
                {
                    return false;
                }
                if (!this.MobilePhone.Equals(s.MobilePhone))
                {
                    return false;
                }
                if (!this.EMail.Equals(s.EMail))
                {
                    return false;
                }
                if (!this.Course.Equals(s.Course))
                {
                    return false;
                }
                if (!this.Uni.Equals(s.Uni))
                {
                    return false;
                }
                if (!this.Faculty.Equals(s.Faculty))
                {
                    return false;
                }
                if (!this.Spcialty.Equals(s.Spcialty))
                {
                    return false;
                }
                return true;
            }

            public override int GetHashCode()
            {
                return this.SSN.GetHashCode();
            }

            public override string ToString()
            {
                return string.Format("{0} {1} {2} -> SSN = {3}, Permanent Address = {4}, Mobile Phone = {5}, e-mail = {6}, Course = {7}, University = {8}, Faculty = {9}, Specialty = {10}", 
                    this.firstName, this.middleName, this.lastName, this.SSN, this.permanentAddress, this.mobilePhone,  
                    this.eMail, this.course, this.uni, this.faculty, this.spcialty);
            }

            public static bool operator ==(Student s1, Student s2)
            {
                return s1.Equals(s2);
            }

            public static bool operator !=(Student s1, Student s2)
            {
                return !(s2.Equals(s2));
            }

            public Student Clone()
            {
                return new Student(this.firstName, this.middleName, this.lastName, this.SSN, this.permanentAddress, this.mobilePhone,
                    this.eMail, this.course, this.uni, this.faculty, this.spcialty);
            }

            object ICloneable.Clone()
            {
                return this.Clone();
            }


            public int CompareTo(Student other)
            {
                string s1Name = this.FirstName + this.MiddleName + this.LastName;
                string s2Name = other.FirstName + other.MiddleName + other.LastName;
                if (s1Name.Equals(s2Name))
                {
                    return this.PSSN.CompareTo(other.PSSN);
                }
                else
                {
                    return s1Name.CompareTo(s2Name);
                }
            }
        }

        static void Main()
        {
            Student s1 = new Student("Andrey", "Kamenov", "Andreev", "21837192dqd", "address", "0883323223", "raztor@abv.bg",
                4, University.SofiaUniversity, Faculty.FacultyOfMathematicsAndInformatics, Specialty.Informatics);
            Student s2 = new Student("Andrey", "Kamenov", "Andreev", "21837192dqd", "address", "0883323223", "raztor@abv.bg",
                4, University.SofiaUniversity, Faculty.FacultyOfMathematicsAndInformatics, Specialty.Informatics);
            Console.WriteLine(s1.CompareTo(s2));
        }
    }
}
